

package com.hazelcast.client.impl.protocol.codec.custom;

import com.hazelcast.client.impl.protocol.ClientMessage;
import com.hazelcast.client.impl.protocol.Generated;
import com.hazelcast.client.impl.protocol.codec.builtin.CustomTypeFactory;

import static com.hazelcast.client.impl.protocol.ClientMessage.BEGIN_FRAME;
import static com.hazelcast.client.impl.protocol.ClientMessage.END_FRAME;
import static com.hazelcast.client.impl.protocol.codec.builtin.CodecUtil.fastForwardToEndFrame;

@SuppressWarnings("unused")
@Generated("f1f52cea2e1ef204a921eda3a11eea74")
public final class MemoryTierConfigCodec {

    private MemoryTierConfigCodec() {
    }

    public static void encode(ClientMessage clientMessage, com.hazelcast.config.MemoryTierConfig memoryTierConfig) {
        clientMessage.add(BEGIN_FRAME.copy());

        CapacityCodec.encode(clientMessage, memoryTierConfig.getCapacity());

        clientMessage.add(END_FRAME.copy());
    }

    public static com.hazelcast.config.MemoryTierConfig decode(ClientMessage.ForwardFrameIterator iterator) {
        // begin frame
        iterator.next();

        com.hazelcast.memory.Capacity capacity = CapacityCodec.decode(iterator);

        fastForwardToEndFrame(iterator);

        return CustomTypeFactory.createMemoryTierConfig(capacity);
    }
}
